#include "../inc/myResManager.h"
#include "../inc/myApplet.h"
namespace Sky
{
	Bool Sky::myResMgr::createPictFromFile( Pict* pict,String* file,PictManager::Callback doneCallback /*= vNull*/ )
	{
		Sky::PictManager mgr;
		StringBuilder sb;
		sb.append(StringPtr(&_mediaDir));
		sb.append(StringPtr(file));
		return mgr.createPictFromFile(sb.toString(),pict,doneCallback);
	}

	Bool myResMgr::createPictFromBuffer( Pict* pict,Buffer* buffer,PictManager::Callback doneCallback /*= vNull*/ )
	{
		Sky::PictManager mgr;
		return mgr.createPictFromBuffer(buffer,pict,doneCallback);
	}

	Bool myResMgr::createPictFromRawBuffer( Pict* pict,Buffer* buffer,PictManager::Callback doneCallback /*= vNull*/ )
	{
		Sky::PictManager mgr;
		return mgr.createPictFromRawBuffer(buffer,pict,doneCallback);
	}

	Bool myResMgr::createFont( Font* font,String* fontName,i32 weight,i32 width,i32 height )
	{
		Sky::FontManager mgr;
		return mgr.createFont(fontName,weight,width,height,font);
	}

	Sky::NType::Void myResMgr::setMeidaDirectory( String* mediaDirectory )
	{
		xAssert(mediaDirectory);
		_mediaDir = *mediaDirectory;
	}

	myApplet* myResMgr::getApplication()
	{
		TreeNode* node = this->getParent();
		while(node)
		{
			if(node->isKindOf(myApplet::Class))
				return (myApplet*)node;
			node = node->getParent();
		}
		return vNull;
	}

}

